'use strict';

const BaseController = require('./base');
const { Op } = require('sequelize');
const serviceName = 'product';

class SchoolController extends BaseController {
  constructor(ctx) {
    super(ctx, serviceName);
  }

  getListQuery(query) {
    let where = {}
    if (query.name) {
      where.name = {
        [Op.like]: `%${query.name}%`
      }
    }
    if (query.category_id) {
      where.category_id = query.category_id
    }
    if (query.ids) {
      // ids是字符串拼接多个id
      where.id = {
        [Op.in]: query.ids.split(',')
      }
    }
    if (query.id) {
      where.id = query.id
    }
    return where
  }
}

module.exports = SchoolController;
